package com.example.aviatorCount.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * 保存的公式数据类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SavedFormula {

    /**
     * 公式名称
     */
    private String name;

    /**
     * 公式描述
     */
    private String description;

    /**
     * 定义的参数
     */
    private Map<String, Parameter> parameters;

    /**
     * 流程图节点数据
     */
    private List<NodeData> nodes;

    /**
     * 流程图连接数据
     */
    private List<ConnectionData> connections;

    /**
     * 生成的计算表达式
     */
    private String expression;

    /**
     * 创建时间
     */
    private Long createTime;

    /**
     * 更新时间
     */
    private Long updateTime;

    /**
     * 参数定义
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Parameter {
        private String id;
        private String name;
        private String type;
        private Object defaultValue;
        private String description;
    }

    /**
     * 节点数据
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class NodeData {
        private String id;
        private String type;
        private String subtype;
        private Map<String, Object> properties;
        private double x;
        private double y;
        private Integer dynamicInputs;
    }

    /**
     * 连接数据
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ConnectionData {
        private String id;
        private PortInfo from;
        private PortInfo to;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class PortInfo {
            private String nodeId;
            private String portType;
            private int portIndex;
        }
    }
}
